{extend name="public/base" /}
{block name="content"}

<style>
    .formDiv {
        height: 100%;
    }

    .blank {
        margin-bottom: 10%;
    }

    .el-pager li {
        font-size: 19px;
    }

</style>


<div class="formDiv">
    <form action="{:url('Index/keywords')}" method="post">
        <div>行业选择：</div>
        <div class="el-input el-input--suffix" style="width: 50%;margin-bottom: 5%">
            <select id="nlType" name="businessType" class="el-input__inner" autocomplete="off" onChange="changeLevel(this)">

                <option value='0' selected='selected'>请选择行业名称</option>
                <?php foreach($busTitle as $k => $v){ ?>
                    <option value='<?php echo $v["id"]; ?>'><?php echo $v['business_name']; ?></option>
                <?php } ?>

            </select>
            <span class="el-input__suffix">
                <span class="el-input__suffix-inner">
                      <i class="el-select__caret el-input__icon el-icon-arrow-down is-reverse"></i>
                </span>
            </span>
        </div>
        <div>关键词名称：</div>
        <input type="text" class="el-input__inner blank" name="businessName" placeholder="请输入关键词名称"/>

        <p/>
        <input type="submit" style="width: 30%;margin-left: 20%" class="el-button el-button--primary"
               value="提交"/>
    </form>

    <div style="margin-top: 5%;">关键词列表：</div>
    <span style="float: right;color: red;font-size: 15px;">注意：爬取数据按钮位于右侧，由于数据量大，请点击后需要耐心等待30秒左右</span>

    <table class="el-table__body" style="width: 820px;border: 5px;">
        <thead>
        <tr class="el-table_row">
            <th>关键词</th>
            <th>行业名称</th>
            <th>添加时间</th>
            <th>最近更新</th>
            <th>是否查询</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <?php if(sizeof($keywordsData) == 0){ ?>
        <tr>
            <td colspan="4" style="text-align: center;font-weight: bold">
                暂时没有数据
            </td>
        </tr>
        <?php }else{ ?>
        <?php foreach($keywordsData as $k => $v){ ?>
        <?php if($k%2 == 0){ ?>
        <tr class="el-table__row" style="background-color: #FDF5E6">
            <td class="el-table_1_column_20" >
                <?php echo $v['keyword']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo getBusinessName($v['bid']); ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo date('Y-m-d',$v['add_time']); ?>
            </td>
            <td class="el-table_1_column_10">
                <?php if($v['upload_time'] == 0){ ?>
                    没有更新
                <?php }else{ ?>
                    <?php echo date('Y-m-d',$v['upload_time']); ?>
                <?php } ?>
            </td>
            <td class="el-table_1_column_10">
                <?php if($v['select_state'] == 0){ ?>
                    <span>未查询</span>
                <?php }else{ ?>
                    <span>已查询</span>
                <?php } ?>
            </td>
            <td class="el-table_1_column_10">

                <button onclick="getSpider(<?php echo $v['id']; ?>)" title="爬取" type="button" class="el-button el-button--primary" value="爬取">
                    <i class="el-icon-share">
                    </i>
                </button>
            </td>
        </tr>
        <?php }else{ ?>
        <tr class="el-table__row el-table__row">
            <td class="el-table_1_column_20" >
                <?php echo $v['keyword']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo getBusinessName($v['bid']); ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo date('Y-m-d',$v['add_time']); ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo date('Y-m-d',$v['upload_time']); ?>
            </td>
            <td class="el-table_1_column_10">
                <?php if($v['select_state'] == 0){ ?>
                     <span>未查询</span>
                <?php }else{ ?>
                     <span>已查询</span>
                <?php } ?>
            </td>
            <td class="el-table_1_column_10">

                <button onclick="getSpider(<?php echo $v['id']; ?>)" title="爬取" type="button" class="el-button el-button--primary" value="爬取">
                    <i class="el-icon-share">
                    </i>
                </button>
            </td>
        </tr>
        <?php } ?>
        <?php } ?>
        <?php } ?>
        </tbody>
    </table>

    <div class="el-pager" style="margin-top: 10%;">
        {$page}
    </div>

</div>

<script type="text/javascript">
    function getSpider(id){

        var ii = layer.load();

        $.ajax({
            type: "POST",
            url: "{:url('Spider/_apiGetTopInfo')}",
            data: {kid: id},
            async: true,
            dataType: "json",
            beforeSend: function () {
                ii = layer.load();
            },
            complete: function (res) {
                layer.close(ii);
                if(res.responseJSON.status == 1){
                    alert(res.responseJSON.msg);
                    window.location.href="/index.php/index/index/website";
                }else{
                    alert(res.responseJSON.msg);
                }

                //location.reload();
                return;
            },
        });


    }
</script>


{/block}
